//@author A0080442N
#include "stdafx.h"
#include "CppUnitTest.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace TaskItUnitTest {		
	TEST_CLASS(TaskItTimeTest) {
	public:
		
		TEST_METHOD(isValidTime1) {
			string time = "2359";
			TaskItTime now;
			bool expected = true;
			bool actual = now.isValidTime(time);
			Assert::AreEqual(expected,actual);
		}
		
		TEST_METHOD(isValidTime2) {
			string time = "0000";
			TaskItTime now;
			bool expected = true;
			bool actual = now.isValidTime(time);
			Assert::AreEqual(expected,actual);
		}
		
		TEST_METHOD(isValidTime3) {
			string time = "8909";
			TaskItTime now;
			bool expected = false;
			bool actual = now.isValidTime(time);
			Assert::AreEqual(expected,actual);
		}
		
		TEST_METHOD(isLaterTime1) {
			string time1 = "2359";
			string time2 = "1000";
			TaskItTime ealier;
			TaskItTime later;
			later.setTime(time1);
			ealier.setTime(time2);
			bool expected = true;
			bool actual = later.isLaterTime(ealier);
			Assert::AreEqual(expected,actual);
		}
		
		TEST_METHOD(isLaterTime2) {
			string time1 = "1800";
			string time2 = "0030";
			TaskItTime ealier;
			TaskItTime later;
			later.setTime(time1);
			ealier.setTime(time2);
			bool expected = false;
			bool actual = ealier.isLaterTime(later);
			Assert::AreEqual(expected,actual);
		}
		
		TEST_METHOD(TaskEdit) {
			string activity ="have lunch";
			string venue = "utown";
			TaskItTime timeStart;
			timeStart.setTime("1000");
			TaskItTime timeEnd;
			timeEnd.setTime("1100");
			string category = "eating";
			Date date;
			date.setDate(120111);
			Task task1(activity, venue, timeStart, timeEnd, category, date);
			string changedActivity = "study";
			task1.editTask(changedActivity,venue,timeStart,timeEnd,category,date);
			string actual = task1.getAllDetails();
			ostringstream taskDetails;
			taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << DISPLAY_ACTIVITY << changedActivity << NEW_LINE;
			taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE <<DISPLAY_VENUE << venue << NEW_LINE;
			taskDetails << DISPLAY_TIME_START << timeStart.getDisplay() << NEW_LINE;
			taskDetails << WHITE_SPACE << DISPLAY_TIME_END << timeEnd.getDisplay() << NEW_LINE;
			taskDetails << WHITE_SPACE << WHITE_SPACE << DISPLAY_CATEGORY << category << NEW_LINE;
			taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE <<DISPLAY_DATE << date.getDisplay() << NEW_LINE;
			taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << DISPLAY_STATUS <<  DISPLAY_NOT_DONE << NEW_LINE;
			string expected = taskDetails.str();
			Assert::AreEqual(expected,actual);
		}
	};
}